<?php
/********************************************************************************
 * 此文件的功能在于对比语言包的差别，以中文（zh-cn）为参考
 * 语言差别会输出到文件 langDiff_[语言].php
 * 同时会自动读取 langReplare_[语言].php，并自动补全到文件
 ********************************************************************************/

exit('已废弃');

$path = LNG_PTH;

$base_setting = $__f_langs['lang_mark_list']['zh-cn'];
$base_arr = File::getFiles($path.$base_setting['mark'], false, 'php');
$l_base = array();
$diff_arr = array();
foreach($__f_langs['lang_mark_list'] as $language => $language_setting){
	if($language == 'zh-cn')continue;
	$langReplare = cache_read('langReplare_['.$language.'].php', '', false);
	if(!is_array($langReplare))$langReplare = array();
	$diff_arr[$language] = array();
	$comp_arr = File::getFiles($path.$language_setting['mark'], false, 'php');
	foreach($base_arr as $file){
		$name = array_shift(explode('.', $file));
		if($name == '_config')continue;
		if(!in_array($file, $comp_arr) && !in_array($name, $langReplare)){
			$diff_arr[$language][$name] = '缺少';
			continue;
		}
		if(!is_array($l_base[$name]))$l_base[$name] = @include LNG_PTH.$base_setting['mark']."/$name.lang.php";
		$l_comp = @include LNG_PTH.$language_setting['mark']."/$name.lang.php";
		if(!is_array($l_base[$name]) || !is_array($l_comp)){
			if(!is_array($l_base[$name]))$diff_arr['zh-cn'][$name] = '有问题';
			if(!is_array($l_comp))$diff_arr[$language][$name] = '有问题';
		}else{
			if(!is_array($langReplare[$name]))$langReplare[$name] = array();
			$replare = 0;			// 是否有修补
			$lang_sync = array();	// 同步回写
			foreach($l_base[$name] as $key => $val){
				if(array_key_exists($key, $l_comp)){
					$lang_sync[$key] = $l_comp[$key];
				}else{
					if(array_key_exists($key, $langReplare[$name])){
						$replare ++;
						$lang_sync[$key] = $langReplare[$name][$key];
					}else{
						if(!isset($diff_arr[$language][$name]))$diff_arr[$language][$name] = array();
						$diff_arr[$language][$name][$key] = $val;
					}
				}
			}
			if($replare > 0){	// 有修补，回写
				//echo LNG_PTH.$language_setting['mark'].'/'.$file."<br />\n";
				cache_write($file, $lang_sync, LNG_PTH.$language_setting['mark']);
			}
		}
	}
	if(empty($diff_arr[$language]))$diff_arr[$language] = '相同';
	
	// 输出到文件缓存
	cache_write('langDiff_['.$language.'].php', $diff_arr[$language]);
}

echo '<pre>';
print_r($diff_arr);
echo '</pre>';
?>